package ro.qi.framework.sys.common;

import ro.qi.framework.sys.i18n.common.Internationalizable;

public class PersonGender extends Internationalizable {

	public static String GENDER_MALE_STRING = "m";
	public static String GENDER_FEMALE_STRING = "f";
	public static int GENDER_MALE_INT = 1;
	public static int GENDER_FEMALE_INT = 2;
	public static String GENDER_NAME_MALE = "Man";
	public static String GENDER_NAME_FEMALE = "Woman";

	public static String GENDER_NAME_PLURAL_MALE = "Men";
	public static String GENDER_NAME_PLURAL_FEMALE = "Women";

	private String stringId = "";
	private int intId = 0;

	public PersonGender(String id) {
		setId(id);
	}
	
	public PersonGender(String id, int localeId) {
		setId(id);
	}
	
	public void setId(String id) {
		if (id.equalsIgnoreCase(GENDER_MALE_STRING)) {
			this.stringId = GENDER_MALE_STRING;
			this.intId = GENDER_MALE_INT;
		} else if (id.equalsIgnoreCase(GENDER_FEMALE_STRING)) {
			this.stringId = GENDER_FEMALE_STRING;
			this.intId = GENDER_FEMALE_INT;
		} else {
			this.stringId = "";
			this.intId = 0;
		}
	}
	
	public void setId(int id) {
		if (id == GENDER_MALE_INT) {
			this.stringId = GENDER_MALE_STRING;
			this.intId = GENDER_MALE_INT;
		} else if (id == GENDER_FEMALE_INT) {
			this.stringId = GENDER_FEMALE_STRING;
			this.intId = GENDER_FEMALE_INT;
		} else {
			this.stringId = "";
			this.intId = 0;
		}
	}
	
	public String getStringId() {
		return stringId;
	}

	public int getIntId() {
		return intId;
	}

	public String getName() {
		if (getStringId().equalsIgnoreCase(GENDER_MALE_STRING) || getIntId() == GENDER_MALE_INT) {
			return GENDER_NAME_MALE;
		} else if (getStringId().equalsIgnoreCase(GENDER_MALE_STRING) || getIntId() == GENDER_FEMALE_INT) {
			return GENDER_NAME_FEMALE;
		} else {
			return "";
		}
	}

	public String getPluralName() {
		if (getStringId().equalsIgnoreCase(GENDER_MALE_STRING) || getIntId() == GENDER_MALE_INT) {
			return GENDER_NAME_PLURAL_MALE;
		} else if (getStringId().equalsIgnoreCase(GENDER_MALE_STRING) || getIntId() == GENDER_FEMALE_INT) {
			return GENDER_NAME_PLURAL_FEMALE;
		} else {
			return "";
		}
	}

}
